<template>
<div style="height:220px;overflow:hidden;">
  <el-card shadow="never" class="box-card">
    <div slot="header" class="clearfix">
      <span>通知</span>
      <div style="float: right; padding: 3px 0" type="text">
        <a href="javascript:;" @click="showDetail()">查看全部 &gt;</a>
      </div>
    </div>
    <el-table :show-header="false" :data="off" class="left_menu_side">
      <el-table-column prop="项目编号" label="通知" class="el-table" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <a @click="showSingle(scope.row)">{{scope.row.subject}}</a>
        </template>
      </el-table-column>
      <el-table-column prop="publisher" :show-overflow-tooltip="true" label="发送人" width="70"></el-table-column>
      <el-table-column prop="publishtime":show-overflow-tooltip="true" label="发布时间" width="148"></el-table-column>
    </el-table>
  </el-card>
</div>
</template>

<script type="text/javascript">
  import { ACCESS_TOKEN, ACCESS_TOKEN_IP } from '@/store/mutation-types'
  import Vue from 'vue'
  import { openIFrame } from '@/utils/util'

  export default {
    data() {
      return {
        off: []
      }
    },
    mounted() {
      this.getAdminList()
    },
    methods: {
      showSingle(record) {
        let baseUrl = process.env.VUE_APP_ADD_HTTP
        let ticket = Vue.ls.get(ACCESS_TOKEN)
        let docid = record.docid
        let url = baseUrl + '/Modules/PublicDocument/view/view.htm?LoginMethod=ssologin&ticket=' +
          ticket + '&id=' + docid + ''
        openIFrame(record.docid, '/Notice/' + record.docid, record.subject, url)
        this.$router.push({ name: record.docid })
      },
      showDetail() {
        let ticket = Vue.ls.get(ACCESS_TOKEN)
        let ReturnUrl = encodeURIComponent('/Modules/PublicDocument/index.htm?request=NoticeList&request_type=2#')
        let baseUrl = process.env.VUE_APP_ADD_HTTP
        let UserIP = "&UserIP="+ Vue.ls.get(ACCESS_TOKEN_IP);
        let url = baseUrl + "/login.xip?LoginMethod=ssologin&Ticket=" + ticket + UserIP + '&ReturnUrl=' + ReturnUrl + ''
        openIFrame("NoticeList", '/NoticeList', '通知列表', url)
        this.$router.push({ name: "NoticeList" })
      },
      getAdminList() {
        let that = this
        let params = {
          serviceName: 'Xinfo.Bus.BL.Service.EgovPlatform.PortalLet.PublicDocmentPortalLetService,Xinfo.Bus.BL.Service',
          guid: 'rcgz_tz',
          getCount: true,
          intTypeId: 3,
          strBizType: '',
          TaskType: 1
        }
        this.getRequest('/PortalLet/GetPortalLetData', params)
          .then(res => {
            res.data.forEach((row, index) => {
              if (index < 5) {
                that.off.push(row)
              }
            })
          })
      }
    }
  }
</script>
<style scoped>
  @media(max-width){
    .el-table{
      width:170px;
    }
  }
  @media(min-width){
    .el-table{
      width:350px;
    }
  }
</style>